@extends('admin.common.main')

@section('cnt')
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span> 用户中心
        <span class="c-gray en">&gt;</span> 修改用户
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <article class="page-container">
        @include('admin.common.validate')
        {{-- 这里的model用于传递主键ID,也可以写['id'=>$model->id] --}}
        <form action="{{ route('admin.user.edit',$model) }}" method="post" class="form form-horizontal" id="form-member-add">
            {{-- 让表单模拟PUT提交 --}}
            @method('put')
            @csrf
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    {{ $model->username }}
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" name="truename"
                           value="{{ $model->truename }}">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>原密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" name="spassword" autocomplete="off">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" id="password" name="password" autocomplete="off">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">确认密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" name="password_confirmation" autocomplete="off">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="sex" type="radio" id="sex-1" value="先生"
                        @if($model->sex == '先生')
                            checked
                        @endif
                        >
                        <label for="sex-1">先生</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-2" name="sex" value="女士"
                         @if($model->sex == '女士')
                             checked
                         @endif
                        >
                        <label for="sex-2">女士</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" name="phone" value="{{ $model->phone }}" >
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="email" class="input-text" name="email" value="{{ $model->email }}" >
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;修改用户&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
@endsection

@section('js')
    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script>
        //单选框的样式
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%',
        });

        //前端表单验证
        //https://www.runoob.com/jquery/jquery-plugin-validate.html
        /*$("#form-member-add").validate({
            rules:{ //验证规则
                truename:{ //表单元素名称
                    required:true   //验证规则
                },
                username:{
                    required:true
                },
                spassword:{
                    required:true
                },
                // password:{
                //     required:true
                // },
                password_confirmation:{
                    equalTo:"#password" //	输入值必须和 #xxx 相同
                },
                email:{
                    email:true
                },
                phone:{
                    phone:true
                }
            },
            messages:{  //消息提示
                truename:{
                    required:'请输入姓名',
                },
                spassword:{
                    required:'请输入原密码',
                }
            },
            onkeyup:false, //回车提交
            success:"valid",
            submitHandler:function(form){
                //验证通过后,处理的方法 form dom对象
                console.log(form)
                form.submit();
            }
        });
*/
        // 自定义验证规则
        jQuery.validator.addMethod("phone", function(value, element) {
            var reg = /^(\+86-)?1[3-9]\d{9}$/;
            return this.optional(element) || (reg.test(value));
        }, "请正确填写您的手机号");
    </script>
@endsection
